package com.eascs.admin.common.dao;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;

import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.mongo.MongoPageQuery;
import com.eascs.app.dao.mongo.MongoSession;

@Repository
public class ProxyMongoDao {

	@Inject
	private MongoSession mongoSessionG;

	public MongoSession getMongoSessionG() {
		return mongoSessionG;
	}

	public void setMongoSessionG(MongoSession mongoSessionG) {
		this.mongoSessionG = mongoSessionG;
	}

	public <T> T findOne(Class<T> entityClass, String keyName, Object keyValue) {
		return mongoSessionG.findOne(entityClass, keyName, keyValue);
	}

	public <T> T findOne(Class<T> entityClass, Object id) {
		return mongoSessionG.findOne(entityClass, id);
	}

	public <T> T deleteOne(Class<T> entityClass, Object id) {
		return mongoSessionG.deleteOne(entityClass, id);
	}

	public <T> void update(T entity) {
		mongoSessionG.update(entity);
	}

	@SuppressWarnings("deprecation")
	public <T> void replace(T entity) {
		mongoSessionG.replace(entity);
	}

	public <T> void insert(T entity) {
		mongoSessionG.insert(entity);
	}

	public <T> PageResult<T> findDataWithPage(MongoPageQuery<T> sqlPageQuery) {
		return mongoSessionG.findDataWithPage(sqlPageQuery);
	}

}
